<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据className获取标签元素</title>
</head>
<body>
    <div class="app">
        <ul>
            <li class="hd"></li>
            <li class="hd hms"></li>
            <li class="hms"></li>
        </ul>
    </div>

    <script>
        function getTagByName(className,node = document){
            const nodes = [];
            Array.from(node.children).map(node => {
                if(node.className.includes(className)) nodes.push(node);
                nodes.push(...getTagByName(className,node));
            })
            return nodes;
        }

        console.log(getTagByName('hd'))
    </script>
</body>
</html>